<?php
/*前台父级控制器*/
namespace app\common\controller;
use think\Controller;
use think\Session;

header("Content-type: text/html; charset=utf-8");
class IndexBase extends Controller
{
	protected $web;
	protected function _initialize()
    {
       // \session('user_info',null);
        parent::_initialize();
        //获取网站配置信息
		$this->web = model('System')->getValue('site_config');
		$this->roule = model('System')->getValue('roule_config');
        $this->assign([
        	'web'=>$this->web,
        	'roule'=>$this->roule,
            'nav'=>$this->getMenu(1),//导航
        ]);
        if(!session('?user_info')){
            Session::set('location_url', request()->domain().request()->url());
            $this->redirect('login/index');
        }
        //todo

    }
    protected function getMenu($nav_cid)
    {
        $menu = model('nav')->where(['nav_cid'=>$nav_cid,'status'=>1])->order(['sort' => 'DESC', 'id' => 'ASC'])->select()->toArray();
        $menu = !empty($menu) ? list_to_tree($menu,'id','pid','child') : [];
        return $menu;
    }
}